#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 18;

vector<int> T[N];
int n,m,cnt,t[N];
ll f[N][N],ans;
bool g[N][N];

int popcnt(int x){int res=0;for(;x;x>>=1) res+=x&1;return res;}

void dfs(int x,int p){
	for(int y : T[x]){if(y == p) continue; dfs(y,x);}	
	for(int nx = 1;nx <= cnt;nx++){
		int u = t[nx];f[x][u] = 1;
		for(int y : T[x]){
			if(y == p) continue; ll s = 0;
			for(int ny = 1;ny <= cnt;ny++){
				int v = t[ny]; if(!g[u][v]) continue;
				s += f[y][v];
			}
			f[x][u] *= s;
		}
	}
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,m = in;
	for(int i = 1,u,v;i <= m;i++) u = in-1,v = in-1,g[u][v] = g[v][u] = 1;
	for(int i = 1,u,v;i < n;i++) u = in-1,v = in-1,T[u].pb(v),T[v].pb(u);
	int U = 1 << n;
	for(int s = 1;s < U;s++){
		cnt = 0; for(int i = 0;i < n;i++) if(s >> i & 1) t[++cnt] = i;
		dfs(0,0); ll tot = 0;
		for(int i = 1;i <= cnt;i++) tot += f[0][t[i]];
		if((n - popcnt(s)) & 1) ans -= tot;else ans += tot;
	}
	printf("%lld\n",ans);
	return 0;
}

